<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>瑞祥集团管理系统</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <link rel="icon" sizes="any" mask="" href="/static/images/rxLogo.png">
    <!-- basics stylesheet -->
    <link rel="stylesheet" href="https://lib.rxjy.com/element-rx/static/basics/css/rxui1.0.2.min.css">
    <!-- <link rel="stylesheet" href="https://lib.rxjy.com/element-rx/static/basics/css/frame.min.css"> -->
    <!-- <link rel="stylesheet" href="https://lib.rxjy.com/element-rx/static/basics/css/page-threecolumn.css"> -->
    <!-- components  stylesheet-->
    <!-- <link rel="stylesheet" href="https://lib.rxjy.com/element-rx/static/components/layer/dist/theme/default/layer.css"> -->
    <!-- <link rel="stylesheet" href="https://lib.rxjy.com/element-rx/static/components/animate.css/animate.min.css"> -->
    <!-- <link rel="stylesheet" href="https://lib.rxjy.com/element-rx/static/components/font-awesome/css/all.min.css"> -->
</head>
<body class="logo-c000000 bar-cffffff nav-black nav-vertical">
    <div id="app">
        <!-- App Render Container-->
        <table class="uiTable">
            <tr>
                <th width="10%">标识</th>
                <th width="80%">备注</th>
                <th width="10%"><span class="cBlue" onclick="addItemsLayer()">添加</span></th>
            </tr>
        </table>
        <div style="height: calc(100vh - 37px);overflow: auto;">
            <table class="uiTable" id="render-items"></table>
        </div>
        <!-- 添加新项 -->
        <div id="add-items" class="plr20" style="display: none">
            <p class="mt20 clearfix">
                <input placeholder="标识" name="id" type="text" class="col-md-12">
            </p>
            <p class="mt20 clearfix">
                <input placeholder="备注" name="name" type="text" class="col-md-12">
            </p>
            <p class="mt20 tx-right">
                <input type="button" class="uiBtn-normal uiBtn-blue" value="确定" onclick="submitAddItem()">
                <input type="button" class="uiBtn-normal uiBtn-gray" value="取消" onclick="layer.closeAll()">
            </p>
        </div>
    </div>
</body>
<!-- basics javascripts -->
<script src="https://lib.rxjy.com/element-rx/static/basics/js/jquery-1.11.3.min.js"></script>
<!-- <script src="https://lib.rxjy.com/element-rx/static/basics/js/frame.min.js"></script> -->
<!-- <script src="https://lib.rxjy.com/element-rx/static/basics/js/rxuedv2.0.min.js"></script> -->
<!-- <script src="https://lib.rxjy.com/element-rx/static/basics/js/jquery.rotate.min.js"></script> -->
<!-- <script src="https://lib.rxjy.com/element-rx/static/basics/js/New_jquery.mousewheel.js"></script> -->
<!-- custom javascripts -->
<!-- <script src="https://lib.rxjy.com/element-rx/static/js/enlargeImg.js"></script> -->
<!-- components javascripts -->
<script src="https://lib.rxjy.com/element-rx/static/components/layer/dist/layer.js"></script>
<script>

// let host = 'http://192.168.1.194:8081'
let host = 'https://zaapi.rxjy.com'

function addItemsLayer () {
    layer.open({
        type: 1,
        title: '添加新项',
        area: ['500px', '200px'],
        content: $('#add-items')
    })
}

function submitAddItem () {
    let _id = $('input[name="id"]').val()
    let _name = $('input[name="name"]').val()
    $.post(host + '/api/DWorksInfo/insertDworkCategory', {
        categoryId: _id,
        categoryName: _name
    }, function (res) {
        if(res.StatusCode === 0) {
            layer.closeAll()
            getDworkCategoryData()
        }else {
            layer.msg(res.StatusMsg, {icon:2})
        }
    })
}

getDworkCategoryData()
function getDworkCategoryData () {
    $.get(host + '/api/DWorksInfo/getDworkCategoryData', function (res) {
        let str = ''
        $.each(res.Body, function (index, item) {
            str +=
            `<tr>
                <td width="10%">${item.dc_categoryId}</td>
                <td width="80%">${item.dc_categoryName}</td>
                <td width="10%"></td>
            </tr>`
        })
        $('#render-items').empty().append(str)
    })
}
</script>
</html>
